/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package drinkcounter.web.servlet.ui;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import drinkcounter.DrinkCounterService;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Toni
 */
@Singleton
public class PartyServlet extends HttpServlet {

    @Inject private DrinkCounterService service;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String partyIdentifier = req.getParameter("id");
        req.setAttribute("party", service.getParty(partyIdentifier));
        req.setAttribute("participants", service.listParticipants(partyIdentifier));
        RequestDispatcher dispatcher = req.getRequestDispatcher("/WEB-INF/party.jsp");
        dispatcher.forward(req, resp);
    }


}
